package IO流;

import java.io.File;

/**
 *使用list（）递归实现子孙级目录打印
 *
 * */
public class File01 {
    public static void main(String[] args) {
        File src = new File("C:\\huangzhi\\workspace\\javaStudy");
        printName(src,0);
    }

    private static void printName(File src, int i) {
        //打印目录级数
        for (int j = 0; j <i ; j++) {
            System.out.print("+");
        }
        System.out.println(src.getName());
        if(!src.exists() ||null == src){
            return;
        }else if (src.isDirectory()){
            for ( File f : src.listFiles()){
                printName(f,i+1);
            }
        }
    }
}
